/**
 * @desc: 收藏效果显示或隐藏
 * 
 * @time: 2012-07-05
 * @author: jack
**/
$(window).ready(function(){
	$(".course").live({
	  mouseover:function(){
		  var shoucangid = $(this).attr("data-id");
		  $('.'+shoucangid).removeClass("hidden");
	  },  
	  mouseout:function(){
		  var shoucangid = $(this).attr("data-id");
		  $('.'+shoucangid).addClass("hidden");
	  }  
	});
})

/**
 * @desc: 收藏状态修改
 * 
 * @time: 2012-07-05
 * @author: jack
**/
$(".shoucanginfo").live("click", function(){
	//1：代表收藏，0：代表取消收藏
	var shoucangstatus = $(this).attr("shoucangstatus");
	var cookid = $(this).attr("cook_id");
	if(cookid)
	{
		$.ajax({
			type:'post',
			url:'/?uajax/addDelCollectInfo',
			data:'&cookid='+cookid+"&status="+shoucangstatus,
			dataType:'json',
			success:function(msg)
			{
				if(msg.data == 'NoLogin')
				{
					logindialog();
				}else if(msg.data == 'HAS')
				{
					alert('此菜谱已收藏！');
				}else if(msg.data == 'EMPTYINFO')
				{
					alert('菜谱不存在！');
				}else if(msg.data == 'ERROR')
				{
					alert('收藏失败！');
				}else
				{
					var num = shoucangstatus == 0 ? 1 : 0;
					$("#shoucangstatus"+cookid).attr("shoucangstatus", num);
					shoucangstatus == 0 ? $("#shoucangstatus"+cookid).removeClass('bu_sc').addClass('bu_qxsc') : $("#shoucangstatus"+cookid).removeClass('bu_qxsc').addClass('bu_sc');
				}
			}
		})
	}
})